package leader.action;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.opensymphony.xwork2.ActionContext;

import leader.service.LeaderService;
import leader.tool.JTableDefine;

import teacher.bean.Teacher;

public class DirectTeacherPrintAction {
	public String execute() {
		Teacher lea=(Teacher) ActionContext.getContext().getSession().get("leader");
//		Teacher lea = new Teacher();
		List<Teacher> lists = new ArrayList<Teacher>();
		LeaderService LS = new LeaderService();
//		lea.setDirection(0);
		lists = LS.selectAllDirectTeacher(lea);
		String[][] columnNames = new String[lists.size()][7];
		columnNames[0] = new String[]{"编号","姓名","工号","职务","学位","邮箱","研究方向"};
		for(int i=1;i<lists.size();i++) {
			Teacher teacher = lists.get(i);
			columnNames[i][0] = String.valueOf(i);
			columnNames[i][1] = teacher.getName();
			columnNames[i][2] = teacher.getUser();
			columnNames[i][3] = teacher.getDuty();
			columnNames[i][4] = String.valueOf(teacher.getDegree());
			columnNames[i][5] = teacher.getMail();
			columnNames[i][6] = teacher.getName();
		}
		int[] px = new int[]{40,70,70,80,50,140,75};
		JTableDefine d = new JTableDefine();
		d.printTable(columnNames,px);
		System.out.println("============================");
		return "success";
	}
}
